/**
 * @file app store
 * @author
 */

import http from '@/api';
import queryString from 'query-string';
const BACKEND_API_PREFIX = process.env.BK_BACKEND_API_PREFIX;
export default {
  namespaced: true,
  state: {
  },
  mutations: {
  },
  actions: {
    getTableData(context, params, config = {}) {
      // eslint-disable-next-line no-undef
      return http.get(`/api/table?&${queryString.stringify(params)}`, params, config);
    },
        getBizData(context, params, config = {}) {
      return http.get(BACKEND_API_PREFIX + `/list`, params, config);
    },
    // 根据业务ID，查询集群列表
    getSetData(context, params, config = {}) {
      const url = BACKEND_API_PREFIX + `/setlist?${queryString.stringify(params)}`;
      return http.get(url, {}, config);
    },
    // 根据业务ID和集群ID，查询模块列表
    getModuleData(context, params, config = {}) {
      const url =BACKEND_API_PREFIX + `/modulelist?${queryString.stringify(params)}`;
      return http.get(url, {}, config);
    },

    getHostData(context, params, config = {}) {
    const url = BACKEND_API_PREFIX +`/hostlist?${queryString.stringify(params)}`;
    return http.get(url, {}, config);
    },
        // 根据传入的主机ID，查询主机详情信息
    getHostDetail(context, params, config = {}) {
    const url = BACKEND_API_PREFIX + `/hostdetail?${queryString.stringify(params)}`;
    return http.get(url, {}, config);
    },
    searchFile(context, params, config = {}) {
      // eslint-disable-next-line no-undef
      const url = BACKEND_API_PREFIX+`/search-file?${queryString.stringify(params)}`;
      return http.get(url, {}, config);
    },
    backupFile(context, params, config = {}) {
            return http.get(`${BACKEND_API_PREFIX}/backup-file?${queryString.stringify(params)}`,
                {}, config);},
    getBackupRecord(context, params, config = {}) {
      // eslint-disable-next-line no-undef
      return http.get(BACKEND_API_PREFIX+`/backup-record`, params, config);
    },
  },
};
